package com.hkjtgc.pcr_app.ui

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatTextView
import com.hkjtgc.pcr_app.R
import com.hkjtgc.pcr_app.util.*
@RequiresApi(Build.VERSION_CODES.M)
class BindingActivity : AppCompatActivity() {

    private lateinit var saveAndExitButton: TextView
    private lateinit var goButton: TextView
    private lateinit var back: ImageView


    @RequiresApi(Build.VERSION_CODES.O)
    @SuppressLint("SetTextI18n", "MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_binding)

        //扫描的卡盒信息
        findViewById<AppCompatTextView>(R.id.machine_id).text =
            "${findViewById<AppCompatTextView>(R.id.machine_id).text} ${intent.getStringExtra("value")}"

        //返回扫描卡盒页面
        back = findViewById(R.id.iv_back)
        back.setOnClickListener {
            finish()
        }

        //todo 前往绑定机器页面
        findViewById<AppCompatTextView>(R.id.tv_next).setOnClickListener {
            val intent = Intent(this, BindingMachineActivity::class.java)
            intent.putExtra("createDate",System.currentTimeMillis().toString())
            intent.putExtra("useInfo","用户相关信息")
            intent.putExtra("simpleInfo","样品管相关信息")
            intent.putExtra("卡盒信息","卡盒相关信息")
            startActivity(intent)
        }

        goButton = findViewById(R.id.go)
        goButton.setOnClickListener {
            val intent = Intent(this, QRCodeActivity::class.java)
            intent.putExtra("type",2)
            startActivity(intent)
        }


        saveAndExitButton = findViewById(R.id.save_exit_button)
        saveAndExitButton.setOnClickListener {
            val time = System.currentTimeMillis()
            time.toString()
            finish()
            BindUtils.bindList.clear()
            startActivity(Intent(this, MainActivity::class.java))
        }







    }

}